

import ApiConfig from "../config/config";


const getStorage = ()=>{
    return wx.getStorageSync(ApiConfig.namespace) || {}
}


const get = (key)=>{
    return getStorage()[key]
}


const set = (key,value)=>{
    let storage = getStorage()
    storage[key] = value
    wx.setStorageSync(ApiConfig.namespace,storage)
}



const remove = (key) => {
    let storage = getStorage()
    delete storage[key]
    wx.setStorageSync(ApiConfig.namespace,storage)
}

/**
 * 清空本地存储的数据
 */
const clear = () => {
    wx.clearStorageSync()
}

export  default {
    get,
    set,
    remove,
    clear
}